<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/**
 * @var yii\web\View $this
 * @var common\models\Category $model
 * @var yii\widgets\ActiveForm $form
 */
?>

<div class="category-form row">
    <div class="col-md-5">
        <?php $form = ActiveForm::begin(); ?>
        <?php
            if(!$model->isNewRecord && $model->parent_id==0){
                echo $form->field($model, 'parent_id')->dropDownList(\common\models\Category::getParentList(true), array('disabled' => true));
            }else{
                echo $form->field($model, 'parent_id')->dropDownList(\common\models\Category::getParentList(true));
            }
        ?>
        <?php  ?>

        <?= $form->field($model, 'category_name')->textInput(['maxlength' => 255]) ?>

        <?= $form->field($model, 'description')->textarea(['rows' => 6]) ?>

        <div class="form-group">
            <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success pull-right' : 'btn btn-primary pull-right']) ?>
        </div>

        <?php ActiveForm::end(); ?>
    </div>
</div>
